import glob
import shutil
import os

def batch_rename_images(directory, new_name):
    count = 1
    #directory2 = "E:\\pythonsource\\数据集\\Light-HaGRID\\inval\\fist\\JPEGImages"
    for filename in glob.glob(directory + "/*.jpg"):  # 使用glob筛选.jpg格式的文件
        new_filename = new_name + str(count) + ".jpg"
        new_path = os.path.join(directory, new_filename)
        shutil.move(filename, new_path)
        count += 1

batch_rename_images("E:\\pythonsource\\数据集\\Light-HaGRID\\inval\\fist\\JPEGImages", "fist")

# #tensorboard --logdir runs/train/exp
# import os
# def myrename(path):
#     file_list=os.listdir(path)
#     for i,fi in enumerate(file_list):
#         old_name=os.path.join(path,fi)
#         new_name=os.path.join(path2,"dislike"+str(i)+".jpg")
#         os.rename(old_name,new_name)
#
# if __name__=="__main__":
#     path="E:\pythonsource\数据集\Light-HaGRID\inval\call\JPEGImages"
#     path2 = "E:\pythonsource\数据集\Light-HaGRID\inval\call\JPEGImagesC"
#     myrename(path)

